library(data.table)
state_results <- fread("../results/state_results.csv")
state_simulations <- fread("../results/state_simulations.csv")
p_biden <- fread("../results/p_biden.csv")
er <- fread("../results/electoral_college_sims.csv")
biden <- round(quantile(er$V2, c(0.05, 0.95)))
trump <- round(quantile(er$V1, c(0.05, 0.95)))
Biden is forcase to win between 243 and 368 electoral college votes. Trump is forecast to win between 162 and 289 electoral college votes (95% uncertainty interval).
biden_likely_winner <- p_biden[p_biden >= 0.9, state]
biden_favored <- p_biden[p_biden > 0.6 & p_biden < 0.9, state]
trump_likely_winner <- p_biden[p_biden < 0.1, state]
trump_favored <- p_biden[p_biden > 0.1 & p_biden < 0.3, state]
tossup <- p_biden[p_biden >= 0.3 & p_biden <= 0.7, state]
Biden is likely to win: California, District of Columbia, Massachusetts, Michigan.
Biden is favored to win: Connecticut, Delaware, Hawaii, Illinois, Maryland, New Hampshire, New Jersey, New Mexico, New York, Oregon, Pennsylvania, Rhode Island, Vermont, Washington.
Trump is likely to win: Kentucky, West Virginia, Wyoming.
Trump is favored to win: Alabama, Arkansas, Idaho, Indiana, Kansas, Louisiana, Mississippi, Missouri, Montana, Nebraska, North Dakota, Oklahoma, South Carolina, South Dakota, Tennessee, Utah
The outcomes in the following states are uncertain at this time: Alaska, Arizona, Colorado, Florida, Georgia, Iowa, Maine, Minnesota, Nevada, New Jersey, North Carolina, Ohio, Oregon, Rhode Island, Texas, Virginia, Wisconsin
Note that uncertainties at this time are due to a) close races and/or b) limited polling data. As more polls become available and election day nears, the outcome of some states marked uncertain will become clearer.
DT::datatable(state_results, options = list(scrollX = TRUE,
scrollY = "200px",
pageLength = 51))
library(tidyverse)
for(s in sort(state_results$State)) {
print(
state_simulations %>%
filter(state == s) %>%
ggplot() +
aes(x = value, fill = candidate, group = NULL, y = ..density..) +
geom_histogram(position = "identity", alpha = 0.6, bins = 50) +
scale_x_continuous(limits = c(0, 1),
breaks = seq(0, 1, 0.1),
labels = paste0(seq(0, 100, 10), "%")) +
scale_fill_manual(values = c("blue", "grey", "red")) +
scale_color_manual(values = c("blue", "grey", "red")) +
geom_vline(aes(xintercept = mean, col = candidate), lty = 2) +
theme_minimal() +
theme(panel.grid.minor = element_blank(),
axis.text.y = element_blank(),
axis.title.x = element_text(size = 9),
legend.position = 'bottom',
plot.title = element_text(size = 15, face = "bold", hjust = 0.5),
plot.subtitle = element_text(size = 9)) +
labs(x = NULL, y = NULL, fill = NULL, col = NULL,
title = paste(s)) +
guides(col = FALSE)
)
}